//
//  JKRTabBarViewController.m
//  百思不得姐
//
//  Created by Lucky on 16/2/29.
//  Copyright © 2016年 Lucky. All rights reserved.
//

#import "JKRTabBarViewController.h"
#import "JKRNavigationController.h"
#import "JKREssenceViewController.h"
#import "JKRFriendTrendsViewController.h"
#import "JKRMeViewController.h"
#import "JKRNewViewController.h"
#import "JKRTabBar.h"

@interface JKRTabBarViewController ()

@end

@implementation JKRTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
    [self setChildViewController:[[JKREssenceViewController alloc] init] title:@"精华" image:[UIImage imageNamed:@"tabBar_essence_icon"] selectedImage:[UIImage imageNamed:@"tabBar_essence_click_icon"]];
    [self setChildViewController:[[JKRNewViewController alloc] init] title:@"新帖" image:[UIImage imageNamed:@"tabBar_new_icon"] selectedImage:[UIImage imageNamed:@"tabBar_new_click_icon"]];
    [self setChildViewController:[[JKRFriendTrendsViewController alloc] init] title:@"关注" image:[UIImage imageNamed:@"tabBar_friendTrends_icon"] selectedImage:[UIImage imageNamed:@"tabBar_friendTrends_click_icon"]];
    [self setChildViewController:[[JKRMeViewController alloc] init] title:@"我" image:[UIImage imageNamed:@"tabBar_me_icon"] selectedImage:[UIImage imageNamed:@"tabBar_me_click_icon"]];
    
    [self setValue:[[JKRTabBar alloc] init] forKeyPath:@"tabBar"];
}

- (void)setChildViewController:(UIViewController *)controller title:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage {
    controller.tabBarItem.title = title;
    controller.tabBarItem.image = image;
    controller.tabBarItem.selectedImage = selectedImage;
    JKRNavigationController *navigationController = [[JKRNavigationController alloc] initWithRootViewController:controller];
    [self addChildViewController:navigationController];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
